<?php
//echo "Debug";
$username = trim("backend");
// password will be changed after publishing to public repository
// if hosting, be sure to change or anyone can cheat!
$password = trim("EdfsD@Fe-f3SK#45L6JHI2I-JklJi9-32kjDFds90-28dskflj!");

$jsonDataObj = json_decode(file_get_contents("php://input"));
$name = htmlspecialchars($jsonDataObj->name);
$attempts = htmlspecialchars($jsonDataObj->attempts);
$seconds = htmlspecialchars($jsonDataObj->seconds);
$postinfo = "name=".$name."&attempts=".$attempts."&seconds=".$seconds;
//echo '<br><br>'.$postinfo.'<br><br>';

// change to your backend if hosting
$url = "http://meambobbo.ddns.net:8080/postScore";

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);

$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>